Matrices with IID Entries

Diagonal Matrices

RandomMatrix.randDiagonalFunction
randDiagonal(d, n) 

randDiagonal(n) 
  • d : default Normal(), entry distribution
  • n : dimension
# Examples

# generates a 3 by 3 diagonal matrix, with non-zero elements from `Normal(0,1)`
julia> randDiagonal(3)

3×3 Diagonal{Float64, Vector{Float64}}:
 0.440359   ⋅         ⋅
  ⋅        1.94832    ⋅
  ⋅         ⋅       -0.52536

# generates a 5 by 5 diagonal matrix, with non-zero elements from `Poisson(2)`
julia> randDiagonal(Poisson(2),5)

5×5 Diagonal{Int64, Vector{Int64}}:
 1  ⋅  ⋅  ⋅  ⋅
 ⋅  0  ⋅  ⋅  ⋅
 ⋅  ⋅  0  ⋅  ⋅
 ⋅  ⋅  ⋅  3  ⋅
 ⋅  ⋅  ⋅  ⋅  3
source

TriangularMatrices

RandomMatrix.randTriangularFunction
randTriangular(d , n ;  diag , Diag, upper ) 

randTriangular(n;diag, upper)
  • d : entry distribution
  • n : dimension
  • diag : default diag = d, diagonal entry distribution
  • Diag : default Diag = true, true includes diagonal, false with diagonal entries 0
  • upper : default upper = true, true gives upper triangular, false gives lower triangular
# Examples 

# Generate an upper triangular matrix with entries Standard Normal
julia> randTriangular(3)

3×3 UpperTriangular{Float64, Matrix{Float64}}:
 -0.572757  -0.459518   -1.60622
   ⋅         0.0216834  -0.416529
   ⋅          ⋅         -1.00807

# Generate a 3 by 3 strictly lower triangular matrix, with nonzero entries uniform from ``\{1,2,3\}`` 
julia> randTriangular(1:3,3,upper=false,Diag=false)

3×3 LowerTriangular{Int64, Transpose{Int64, Matrix{Int64}}}: 
 0  ⋅  ⋅
 3  0  ⋅
 3  2  0
source

Full Matrices

RandomMatrix.randMatrixFunction
randMatrix(d::D, n::Int, m = n::Int; norm = false::Bool) where D<:S

randMatrix(n::Int, m = n::Int; norm = false::Bool)
  • d : entry distribution
  • n,m : default m = n , dimensions
  • norm : default false, if norm set to true, then the matrix will be normlaized with $min{n,m}^(-1/2)$.
# Examples

# Generates a 2 by 2 random  matrix with entries from the Standard  Gaussian.
julia> randMatrix(2)

2×2 Matrix{Float64}:
 1.74043  -1.30317
 0.72765   0.639943

# Generates a 3 by 2 random  matrix with entries uniformly from {1,2,3,...,10}.
julia> randMatrix(1:10,3,2)

3×2 Matrix{Int64}:
  1  3
  6  4
 10  1

# Generate a normalized random 2 by 2  Matrix with entries  `Poisson(2)` rvs. 
# Need to import the `Distributions` package for `Poisson(2)`
julia> randMatrix(Poisson(2),2,norm = true)

2×2 Matrix{Float64}:
 1.41421   0.0
 0.707107  1.41421
source
using Plots, RandomMatrix, LinearAlgebra
N = 500
M = randMatrix(N)
colors = [:red,:green,:blue,:purple]
@gif for n = (1:50...,51:10:N...,N:-10:51...,50:1...)

    M[1:n,1:n]/sqrt(n)|>eigvals|>x->scatter(x,ylims=(-1.25,1.25), xlims=(-1.25,1.25),ratio=1,label="n = $(n)",size=(800,800))

    plot!([exp(θ*im) for θ=0:0.01:2pi],label="",lw=3,c=[rand(colors) for _=0:0.01:2pi])

    title!("Circular Law for IID Matrices")

end